#ifndef LT_FUDP_SERVER
#define LT_FUDP_SERVER

#include "../../Configure/header/common_conf.hpp"

#include <iostream>

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <map>

using namespace std;

class fudpServer
{
private:
    int fd;

    struct threadARG{
        fudpServer* handler;
        char* filename;
        int newSocket;
        int temp_port;
        struct sockaddr_in addressClient;
    };

    static queue<int> client_vector;

    static map<int,struct threadARG> runningThread;

public:
    // currently not multithead
    fudpServer();

    // begin to listern
    void listern();

    void handleHandshake(char* _msg, struct sockaddr_in& addressClient);

    static void handleClose(int port);

    // a function to handle a send
    static void* handleSend(void* arg);

    static void* handleGet(void* arg);
    
    int initSocket(int port);
};


#endif // !FUDP_SERVER


